package com.woniu.fly.fairmall.admin.web;

import com.woniu.fly.fairmall.core.util.ResponseUtil;
import com.woniu.fly.fairmall.db.service.FairmallUserService;
import com.woniu.fly.fairmall.db.service.QuestMainService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/admin/dashboard")
@Validated
public class AdminDashbordController {
    private final Log logger = LogFactory.getLog(AdminDashbordController.class);

    @Resource
    private FairmallUserService userService;

    @Resource
    private QuestMainService questMainService;

    @GetMapping("")
    public Object info() {
        long userTotal = userService.count();
        long questTotal = questMainService.count();
        // int goodsTotal = goodsService.count();
        // int productTotal = productService.count();
        // int orderTotal = orderService.count();
        Map<String, Long> data = new HashMap<>();
        data.put("userTotal", userTotal);
        data.put("goodsTotal", questTotal);
        // data.put("productTotal", productTotal);
        // data.put("orderTotal", orderTotal);

        return ResponseUtil.ok(data);
    }

}
